package com.util.description;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yutianhong
 * @version 1.0
 * @since 2024/01/01 23:18
 */
public interface WildcardTypeDesc extends TypeDesc {

    static WildcardTypeDesc of(List<TypeDesc> upperBounds, List<TypeDesc> lowerBounds) {
        return new DefaultWildcardTypeDesc(upperBounds, lowerBounds);
    }

    @Override
    default boolean isWildcard() {
        return true;
    }

    @Override
    default String className() {
        return "?";
    }

    List<TypeDesc> getUpperBounds();

    List<TypeDesc> getLowerBounds();
}

class DefaultWildcardTypeDesc implements WildcardTypeDesc {
    List<TypeDesc> upperBounds;
    List<TypeDesc> lowerBounds;

    public DefaultWildcardTypeDesc(List<TypeDesc> upperBounds, List<TypeDesc> lowerBounds) {
        this.upperBounds = new ArrayList<>(upperBounds);
        this.lowerBounds = new ArrayList<>(lowerBounds);
    }

    @Override
    public List<TypeDesc> getUpperBounds() {
        return upperBounds;
    }

    @Override
    public List<TypeDesc> getLowerBounds() {
        return lowerBounds;
    }
}



